var name_input = document.getElementsByClassName('username')[0];
var pwd_input = document.getElementsByClassName('password')[0];
var btnEle = document.getElementsByClassName('button')[0];

var usernameflag = false;
var passwordflag = false;
btnEle.onclick = function(){
    alert('正确');
}
name_input.onblur = function () {
    var reg = /^[0-9a-zA-Z_-]{4,16}$/;
    var username = document.getElementsByClassName('username')[0].value;
    var usernameflag = reg.test(username);
    var check_name = document.getElementsByClassName('error_name')[0];
    if (usernameflag) {
        check_name.innerHTML = '';
    } else {
        check_name.innerHTML = '用户名格式不正确';
    }
    controlBtnDisabled;
}
pwd_input.onblur = function () {
    var reg1 = /^[0-9a-zA-Z_]{5,18}$/;
    var password = document.getElementsByClassName('password')[0].value;
    var passwordflag = reg1.test(password);
    var check_pwd = document.getElementsByClassName('error_pwd')[0];
    if (passwordflag) {
        check_pwd.innerHTML = '';
    } else {
        check_pwd.innerHTML = '密码格式不正确';
    }
    controlBtnDisabled;
}
function controlBtnDisabled(){
console.log('usernameflag',usernameflag);
console.log('passwordflag',passwordflag);
console.log(!usernameflag && !passwordflag);
btnEle.disabled = !(usernameflag && passwordflag);
}



